package com.yzt.zhuju.dialog;

import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.yzt.zhuju.R;
import com.yzt.zhuju.widget.tuiview.TUITextView;

/**
 * 直播页面踢出房间时间设置
 */
public class ChatRoomKickActionDialog extends NewBaseBottomDialog implements View.OnClickListener {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_chat_room_kick_action, container, false);
        initView(view);
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        Dialog dialog = getDialog();
        Window window = dialog.getWindow();
        if (window != null) {
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            WindowManager.LayoutParams params = window.getAttributes();
            params.gravity = Gravity.BOTTOM;
            params.width = ViewGroup.LayoutParams.MATCH_PARENT;
            params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            window.setAttributes(params);
        }
        dialog.setCanceledOnTouchOutside(true);
    }


    private void initView(View view) {
        TextView kick1 = view.findViewById(R.id.tv_kick1);
        TextView kick2 = view.findViewById(R.id.tv_kick2);
        TextView kick3 = view.findViewById(R.id.tv_kick3);
        TUITextView tvActionCancel = view.findViewById(R.id.tv_action_cancel);

        kick1.setOnClickListener(this);
        kick2.setOnClickListener(this);
        kick3.setOnClickListener(this);
        tvActionCancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int viewId = view.getId();
        if (viewId == R.id.tv_kick1) {
            // 踢出一小时
            mDialogFragmentResultListener.confirm("1");
        } else if (viewId == R.id.tv_kick2) {
            // 踢出一天
            mDialogFragmentResultListener.confirm("24");
        } else if (viewId == R.id.tv_kick3) {
            // 永久踢出
            mDialogFragmentResultListener.confirm("-1");
        }
        dismiss();
    }
}


